<template>
  <image
    :src="urlImg"
    mode="heightFix"
    style="height: 60rpx"
    @click="getCode"></image>
</template>

<script setup>
  import http from '@/utils/request.js'
  import { ref } from 'vue'
  import { onLoad } from '@dcloudio/uni-app'

  const uid = defineModel({
    type: String,
    default: ''
  })

  const urlImg = ref('')

  const getCode = async () => {
    const { img, uuid } = await http.get('/api/free/captchaImage')
    urlImg.value = `data:image/gif;base64,${img}`
    uid.value = uuid
  }

  onLoad(() => {
    getCode()
  })
</script>
